package edu.qichen.onlineBlog.framework.exception;

import edu.qichen.onlineBlog.framework.DataResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 功能:全局异常
 * 作者:程序员欧阳子韩
 * 日期:2024/4/6 19:06
 */
@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public DataResult<Void> BusinessException(BusinessException e) {
        return DataResult.fail(e.getErrCode(), e.getErrMsg());
    }

//    /**
//     * 请求错误
//     *
//     * @return -
//     */
//    @ExceptionHandler(Exception.class)
//    @ResponseBody
//    public DataResult<Void> RequestGlobalException() {
//        return DataResult.fail(ErrorCodeEnum.SERVER_REQUEST_ERROR);
//    }
}
